package org.example;

import java.util.ArrayList;
import java.util.List;

public class MarkDownTemplate extends AbstractMarkDownTemplate {
    @Override
    public String[] template(ClassInfo classInfo, MarkDownOperation op) {
        List<String> fields = new ArrayList<>();

        fields.add("Qualifier and Type");
        fields.add("Method Name");
        fields.add("Description");

        List<MethodInfo> methodsInfo = classInfo.getMethodsInfo();

        List<List<String>> form = new ArrayList<>();
        for (int i = 0;i < methodsInfo.size();i++){
            MethodInfo methodInfo = methodsInfo.get(i);
            ArrayList<String> record = new ArrayList<>();
            record.add(methodInfo.getReturnType());
            record.add(methodInfo.getMethodName());
            record.add(methodInfo.getMethodComments());

            form.add(record);
        }

        return new String[]{
                op.addHead("类名", 2),
                op.addCodeStatement(classInfo.className) + "\n\r",
                op.addHead("方法", 2),
                op.addForm(form,fields)
        };
    }
}
